package com.tbit.uqbike.client.service;

import cn.hutool.core.date.DateTime;
import com.tbit.uqbike.client.pojo.Account;
import com.tbit.uqbike.client.pojo.Recharge;
import com.tbit.uqbike.client.pojo.User;
import com.tbit.uqbike.client.pojo.dto.RefundMoneyReturnDTO;
import com.tbit.uqbike.client.pojo.newEntity.*;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Author: chen
 * @Description: 汇付天下聚合支付
 * @Date: 创建于 15:19 2021/9/2
 */
public interface AdaPayService {

    /**
     * 创建充值订单
     *
     * @param user
     * @param money
     * @param remark
     * @param deposit
     * @param adAccountId
     * @param rechargeType
     * @return
     */
    Map<String, Object> createOrder_wx_xcx(User user, Double money, String code, String remark,
                                           Boolean deposit, Integer adAccountId, Integer rechargeType);

    /**
     * 免押会员小程序微信支付
     *
     * @param code
     * @param
     * @param user
     * @param memberFeeId
     * @return
     */
    Map<String, Object> getMemberOrder_wx_xcx(String code, User user, Integer memberFeeId,
                                              Integer adAccountId);

    /**
     * 骑行会员小程序支付
     *
     * @param code
     * @param
     * @param rideCardId
     * @return
     */
    Map<String, Object> getRideCardOrder_wx_xcx(String code, User user, Integer rideCardId,
                                                Integer adAccountId);

    /**
     * 会员卡小程序微信支付
     *
     * @param code
     * @param
     * @param user
     * @param vipId
     * @return
     */
    Map<String, Object> getVipOrder_wx_xcx(String code, User user, Integer vipId, Integer adAccountId);

    /**
     * 优惠券套餐小程序微信支付
     *
     * @param code
     * @param
     * @param user
     * @param mealId
     * @return
     */
    Map<String, Object> getMeal_wx_xcx(String code, User user, Integer mealId, Integer adAccountId);


    /**
     * 创建充值订单
     *
     * @param user
     * @param money
     * @param remark
     * @param deposit
     * @param adAccountId
     * @param rechargeType
     * @return
     */
    Map<String, Object> createOrder_zfb_xcx(User user, Double money, String code, String remark,
                                            Boolean deposit, Integer adAccountId, Integer rechargeType);

    /**
     * 免押会员小程序微信支付
     *
     * @param code
     * @param
     * @param user
     * @param memberFeeId
     * @return
     */
    Map<String, Object> getMemberOrder_zfb_xcx(String code, User user, Integer memberFeeId,
                                               Integer adAccountId);

    /**
     * 骑行会员小程序支付
     *
     * @param code
     * @param
     * @param rideCardId
     * @return
     */
    Map<String, Object> getRideCardOrder_zfb_xcx(String code, User user, Integer rideCardId,
                                                 Integer adAccountId);

    /**
     * 会员卡小程序微信支付
     *
     * @param code
     * @param
     * @param user
     * @param vipId
     * @return
     */
    Map<String, Object> getVipOrder_zfb_xcx(String code, User user, Integer vipId,
                                            Integer adAccountId);

    /**
     * 优惠券套餐小程序微信支付
     *
     * @param code
     * @param
     * @param user
     * @param mealId
     * @return
     */
    Map<String, Object> getMeal_zfb_xcx(String code, User user, Integer mealId, Integer adAccountId);

    /**
     * 延时分账
     * @param money 分账金额
     * @param user 用户信息
     * @param adAccountId 区域id
     * @param orderNO 骑行单号
     * @param rideMoney 骑行金额
     */
    void delay(Double money, User user, Integer adAccountId, String orderNO,Integer rideMoney);

    /**
     * 检验是否支持特定支付
     *
     * @param accountId
     */
    void checkIsAdaPay(Integer accountId);

    /**
     * 用户退款功能
     *
     * @param money      退款金额
     * @param fineMoney  退罚款金额
     * @param userId     用户id
     * @param buyOrderNO 业务订单号
     * @return
     */
    Double refundMoney(Double money, Long fineMoney, Integer userId, String buyOrderNO, AdaPayConfig adaPayConfig,
                       Integer adAccountId, Integer operatorId, String operatorName, String operatorPhone, Integer sendMsg, String remark);

    /**
     * 用户退款功能（新）
     *
     * @param money      退款金额
     * @param fineMoney  退罚款金额
     * @param userId     用户id
     * @param buyOrderNO 业务订单号
     * @return
     */
    RefundMoneyReturnDTO refundMoneyNew(Double money, Long fineMoney, Integer userId, String buyOrderNO, AdaPayConfig adaPayConfig,
                                        Integer adAccountId, Integer operatorId, String operatorName, String operatorPhone, Integer sendMsg, String remark);


    /**
     * 添加日志
     *
     * @param recharge    订单
     * @param adAccountId 区域id
     * @param refundNO    退款订单号
     * @param refundMoney 退款金额
     * @param userId      用户id
     */
    void addRefundLog(Recharge recharge, Integer adAccountId, String refundNO, Double refundMoney,
                      Integer userId, String remark);

    String getDepositAccount(Integer accountId);

    void addAdaPayRefundLog(List<UserAdaPayLog> userAdaPayLogs, List<DivMembers> divMembers, String orderNO, Integer money, Integer refundServiceFee, Integer fee);

    /**
     * 余额退款
     *
     * @param recharge     充值订单
     * @param adaPayConfig 支付配置
     * @param isCashAll    是否全额分账
     * @param user         用户信息
     * @return
     */
    double refund(Account account, Recharge recharge, AdaPayConfig adaPayConfig, boolean isCashAll, User user,
                  Double refundMoney, String refundNO, String refundBusinessNO, Integer operatorId, String operatorName,
                  String operatorPhone, String rideOrderNo, String transactionLogRemark);

    double refundNew(Account account, Recharge recharge, AdaPayConfig adaPayConfig, boolean isCashAll, User user, Double money,
                      String refundNO, String refundBusinessNO, Integer operatorId, String operatorName, String operatorPhone,
                      String rideOrderNo, String transactionLogRemark,Integer sendMsg,boolean isApi, String refundBatch);

    /**
     * 查询是否开启充值金额直接分账
     *
     * @param accountId
     * @return
     */
    boolean getPayType(Integer accountId);

    /**
     * 添加订单详情记录
     *
     * @param orderNO
     * @param adAccountId
     * @param user
     * @param money
     * @param rideMoney
     * @param type
     * @return
     */
    public RideFeeLog addRideFeeLog(String orderNO, Integer adAccountId, User user, Integer money,
                                    Integer rideMoney, Integer type);


    /**
     * 推送退款明细
     *
     * @param user
     * @param account
     * @param refundMoney
     * @param refundNO
     * @param refundBusinessNO
     * @param recharge
     */
    void pushRefundDetailLog(User user, Account account, Double refundMoney, String refundNO, String refundBusinessNO,
                             Recharge recharge, Integer operatorId, String operatorName,
                             String operatorPhone, Integer businessType, String rideOrderNo, String transactionLogRemark,Date time);

    /**
     * 推送退款日志
     *
     * @param user
     * @param account
     * @param refundMoney
     * @param businessNO
     * @param merchantNOList
     * @param recharge
     */
    void pushRefundLog(User user, Account account, Double refundMoney, String businessNO,
                       List<String> merchantNOList, Recharge recharge, Integer changeType, String rideOrderNo
            , Integer operatorId, String operatorName, String operatorPhone, String remark, Date time);



    void editRefund(AdaPayLog adaPayLog, Double feeMoney, String orderNO, User user, boolean isReduce, String remark);

    void editUserAdaPayLog(List<DivMembers> divMembers, String adaPayId, Integer allRefundMoney
            , Integer refundFee, Integer refundServiceFee, String mainUserNO, String buyOrderNo, DateTime time);

    Map<String, List<DivMembers>> getRefundDivMember(List<UserAdaPayLog> userAdaPayLogs, double money, Integer accountId);

}
